package com.wjw.java.collection.generic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Generic_Exercise {
    public static void main(String[] args) {
        Cat c1 = new Cat(1001L,"小黑猫");
        Cat c2 = new Cat(1002L,"小白猫");
        Cat c3 = new Cat(1003L,"小灰猫");
        List<Cat> catList = new ArrayList<>();
        catList.add(c1);
        catList.add(c2);
        catList.add(c3);
        System.out.println(catList);

        Map<Long,Cat> catMap = new HashMap<>();
        catMap.put(c1.getId(),c1);
        catMap.put(c2.getId(),c2);
        catMap.put(c3.getId(),c3);
        System.out.println(catMap);
    }
}
class Cat{
    private Long id;
    private String name;

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Cat() {}

    public Cat(Long id, String name) {
        this.id = id;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}
